mergeInto(LibraryManager.library, { 
  
    UnityInitCompleted:function(msg)
    {
       window.UnityInitCompleted();
    }, 
    AddNumbers: async function (x, y, onSuccess) {
        console.log("AddNumbers onSuccess type:",typeof onSuccess,onSuccess);
        await new Promise(resolve => setTimeout(resolve, 2000));
        dynCall_vi(onSuccess, x + y);
    },
      
    UnityAsync:async function (x, y, onSuccess) {
          console.log("onSuccess type:",typeof onSuccess,onSuccess);                  
          window.UnityAsync(x,y,onSuccess);
    },
    
   UnityAsyncStr:function (key, content, onSuccess) { 
          window.UnityAsyncStr(key,content,onSuccess); 
   },
    
    
   UnityAsyncStr2:function (key, content, onSuccess) {  
        var returnStr = "error";    
        var bufferSize = lengthBytesUTF8(returnStr) + 1;
        var buffer = _malloc(bufferSize);
        stringToUTF8(returnStr, buffer, bufferSize);
        
       console.log(returnStr,bufferSize,buffer,[buffer]); 
       dynCall_vi(onSuccess, [buffer]);
   },
   
   
   TestJsStr:function() { 
        window.TestJsStr2 =TestJsStr2;
           var returnStr = window.getSocketToken();
           
                var bufferSize = lengthBytesUTF8(returnStr) + 1;
                var buffer = _malloc(bufferSize);
                stringToUTF8(returnStr, buffer, bufferSize);
                
                 console.log(returnStr,bufferSize,buffer,[buffer]); 
           return buffer;
       },   
       
  TestJsStr2:function(returnStr) { 
          
               var bufferSize = lengthBytesUTF8(returnStr) + 1;
               var buffer = _malloc(bufferSize);
               stringToUTF8(returnStr, buffer, bufferSize);
               
                console.log(returnStr,bufferSize,buffer,[buffer]); 
          return buffer;
      },  
 
});
